home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Disk / moni / FileX-src.lha / FileX-src / Iconify.c < prev    next >
C/C++ Source or Header  |  1994-04-20  |  3KB  |  156 lines

  1. #include "allprotos.h"
  2. #include "filexstrings.h"
  3. #include "filexstructs.h"
  4.  
  5. static struct DiskObject *dobj;        /* Iconifydaten */
  6. static struct AppIcon *appicon;
  7. static struct MsgPort *AppIconPort;
  8.  
  9. void DoAppIconMessage( void )
  10. {
  11.     struct AppMessage *appMsg;
  12.     long k;
  13.  
  14.     while( AppIconPort && (appMsg = (struct AppMessage *)GetMsg(AppIconPort)))
  15.     {
  16.         if( appMsg->am_Type == 8 )        /* AppIcon aktiviert */
  17.         {
  18.             UBYTE buffer[256] = "";
  19.  
  20.             if( appMsg->am_NumArgs == 0 )
  21.             {
  22.                 RemoveIconify();
  23.             }
  24.             else
  25.             {
  26.                 struct WBArg *argptr;
  27.  
  28.                 argptr = appMsg->am_ArgList;
  29.  
  30.                 for( k = 0; ( k < appMsg->am_NumArgs ) && ( mainflags & MF_ICONIFIED ); k++, argptr++)
  31.                 {
  32.                     if( strlen( argptr->wa_Name ))
  33.                     {
  34.                         NameFromLock( argptr->wa_Lock, buffer, 256 );
  35.  
  36.                         AddPart( buffer, argptr->wa_Name, 256 );
  37.  
  38.                         if(strlen(buffer))
  39.                         {
  40.                             if( QuitView( 5, AktuDD ))
  41.                                 MyOpen(buffer,AktuDD);
  42.                         }
  43.  
  44.                         RemoveIconify();
  45.                     }
  46.                 }
  47.             }
  48.         }
  49.  
  50.         ReplyMsg((struct Message *)appMsg);
  51.     }
  52. }
  53.  
  54. static long premf;
  55.         
  56. BOOL MakeIconify( void )
  57. {
  58.     if( mainflags & MF_ICONIFIED )
  59.         return( TRUE );
  60.  
  61.     premf = mainflags;
  62.  
  63.     if( mainflags & MF_CLIPCONV )
  64.         CloseClipConv();
  65.  
  66.     if( mainflags & MF_CALC )
  67.         CloseCalc();
  68.  
  69.     if( CloseDisplay())
  70.     {
  71.             /* AppMessagePort erstellen */
  72.  
  73.         if(AppIconPort=CreateMsgPort())
  74.         {
  75.             MyAddSignal( 1L << AppIconPort->mp_SigBit, &DoAppIconMessage);
  76.  
  77.             if( !( dobj = GetDiskObjectNew( programname )))
  78.             {
  79.                 BPTR NewLock;
  80.     
  81.                 if(NewLock = Lock("PROGDIR:",ACCESS_READ))
  82.                 {
  83.                     BPTR OldLock;
  84.     
  85.                     OldLock = CurrentDir(NewLock);
  86.     
  87.                     dobj = GetDiskObjectNew( FilePart( programname ));
  88.     
  89.                     CurrentDir(OldLock);
  90.     
  91.                     UnLock(NewLock);
  92.                 }
  93.             }
  94.         
  95.             if( dobj )
  96.             {
  97.                 dobj->do_Type = 0;
  98.         
  99.                 if( appicon = AddAppIconA( 0, 0, GetStr(MSG_APPICONNAME), AppIconPort, NULL, dobj, NULL ))
  100.                 {
  101.                     mainflags |= MF_ICONIFIED;
  102.     
  103.                     return( TRUE );
  104.                 }
  105.         
  106.                 FreeDiskObject( dobj );
  107.             }
  108.  
  109.                 /* AppIconPort freigeben */
  110.  
  111.             MyRemoveSignal( 1L << AppIconPort->mp_SigBit );
  112.             DeleteMsgPort( AppIconPort );
  113.             AppIconPort = NULL;
  114.         }
  115.  
  116.         OpenDisplay();
  117.     }
  118.  
  119.     if( premf & MF_CLIPCONV )
  120.         OpenClipConv();
  121.  
  122.     if( premf & MF_CALC )
  123.         OpenCalc();
  124.  
  125.     return( FALSE );
  126. }
  127.  
  128. void RemoveIconify( void )
  129. {
  130.     if(! ( mainflags & MF_ICONIFIED ))
  131.         return;
  132.  
  133.     RemoveAppIcon(appicon);
  134.  
  135.         /* AppIconPort freigeben */
  136.  
  137.     MyRemoveSignal( 1L << AppIconPort->mp_SigBit );
  138.     DeleteMsgPort( AppIconPort );
  139.     AppIconPort = NULL;
  140.  
  141.     FreeDiskObject(dobj);
  142.  
  143.     OpenDisplay();
  144.  
  145.     if( premf & MF_CLIPCONV )
  146.         OpenClipConv();
  147.  
  148.     if( premf & MF_CALC )
  149.         OpenCalc();
  150.  
  151.     ActivateWindow( AktuDI->Wnd );
  152.     WindowToFront( AktuDI->Wnd );
  153.  
  154.     mainflags &= ~MF_ICONIFIED;
  155. }
  156.